const ItemService = require("../service/item.service")

class EnterController {
    async list(ctx,next) {
        const { stashId,categoryId } = ctx.query
        const result = await ItemService.getListByStashIdAndCategoryId(stashId,categoryId)
        ctx.body = result
    }
    async recordList(ctx,next) {
        const page = ctx.query.page || 1
        const pageSize = ctx.query.pageSize || 10
        const {totalCount} = await ItemService.getListCount()
        const offset = (page - 1) * pageSize

        const items = await ItemService.getList(pageSize,offset)

        ctx.body = {
            totalCount,
            items
        }
    }
    async last7DayList(ctx,next) {
        const result = await ItemService.getLast7DataList()
        
        console.log(result);
        ctx.body = "近七天的数据"
    }
    async byCategoryList(ctx,next) {
        const result = await ItemService.getCategoryEnterAndOut()
        ctx.body = result
    }
}

module.exports = new EnterController()